//
//  HDCFImgLinkVc.m
//  HaoDeCaiFu
//
//  Created by 郑开宏 on 2017/12/2.
//  Copyright © 2017年 郑开宏. All rights reserved.
//

#import "HDCFImgLinkVc.h"
#import <WebKit/WebKit.h>

@interface HDCFImgLinkVc ()<WKUIDelegate, WKNavigationDelegate>
@property (nonatomic, weak) WKWebView *webView;
@end

@implementation HDCFImgLinkVc

- (void)setImgLinkUrl:(NSString *)imgLinkUrl{
    _imgLinkUrl = imgLinkUrl;
}

- (void)setName:(NSString *)name{
    _name = name;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.navigationItem setTitle:_name];
    [SVProgressHUD show];
    CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - KNavHeight);
    WKWebView *webview = [[WKWebView alloc] initWithFrame:rect];
    webview.navigationDelegate = self;
    NSString *urlString = [NSString stringWithFormat:@"http://jx.chinahonden.xyz:15504%@", _imgLinkUrl];
    [webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
    [self.view addSubview:webview];
    _webView = webview;
}

- (void)initData{
    NSString *urlString = [NSString stringWithFormat:@"http://jx.chinahonden.xyz:15504%@", _imgLinkUrl];
    [_webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:urlString]]];
}

-(void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation{
    
}

-(void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation{
    
}

-(void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation{
    [SVProgressHUD dismiss];
    
}

- (void)webView:(WKWebView *)webView didFailProvisionalNavigation:(WKNavigation *)navigation
{
    [SVProgressHUD dismiss];
    [self initData];
}

@end
